package titt.io.socket.in;

import java.io.InputStream;

import titt.io.socket.TITTSocket;

public class SocketCloser implements TITTInputStream {

	private final TITTInputStream in;
	private final TITTSocket sock;
	
	public SocketCloser(TITTSocket sock, TITTInputStream in) {
		this.in = in;
		this.sock = sock;
	}
	
	@Override
	public InputStream asStream() {
		return in.asStream();
	}

	@Override
	public void close() throws Exception {
		in.close();
		sock.close();
	}

	@Override
	public void read(byte[] buffer) throws Exception {
		in.read(buffer);
	}

	@Override
	public byte[] readFully() throws Exception {
		return in.readFully();
	}

	@Override
	public byte[] readLine() throws Exception {
		return in.readLine();
	}

}
